Developer Documentation
PATH  Mac OS X Documentation > Cocoa > Application Design for Scripting, Documents, and Undo


Previous | Chapter contents | Next | Book PDF

Type Information and NSDocumentControllers

An NSDocumentController object manages documents. It keeps track of all open documents; it knows how to create new documents and how to open existing documents. It knows how to find open documents given either a window that is part of the document or the path of the file a document was loaded from. Developers typically won't have to worry about what it does. NSDocumentController knows how to read and use the metadata that a document-based application provides about the types of documents it can open. NSDocumentController can provide information based on that metadata, such as lists of file types supported by an application and which NSDocument subclasses are used for them.

All document-based applications declare information about the document types they support in the information property list ( CustomInfo.plist ) of the application. Currently, no development tools directly support the creation of this metadata, so you must create it by hand. See the NSDocumentController class specification for details on the CustomInfo.plist keys required by the document architecture and how to include this metadata in your application project.

The metadata in the information property list declares the types of documents supported by an application. The Yellow Box defines a set of abstract types; these types are usually the same thing as the pasteboard type that represents such data. For each abstract type, the CustomInfo.plist lists specific information such as

NSDocumentController loads all this type information and uses it. When NSDocumentController runs an open panel it obtains the list of all file extensions for document types that your application can read; it passes that list to the open panel so that it can list the files that can be opened. When the user actually chooses a file to open, the NSDocumentController uses the metadata to identify the subclass of NSDocument to use to create the document and load its data.


Application Design for Scripting, Documents, and Undo

Previous | Chapter contents | Next | Book PDF